<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('发布生产实习')"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-role-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">名称：</label>
            <div class="col-sm-8">
                <input class="form-control" id="productionName" name="productionName" required type="text" value="生产实习">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">申请要求：</label>
            <div class="col-sm-8">
                <textarea class="form-control" id="productionRequire" name="productionRequire" required
                          type="text"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">开始时间：</label>
            <div class="col-sm-8">
                <input class="form-control" id="productionBegin" name="productionBegin" placeholder="年-月-日" required
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">结束时间：</label>
            <div class="col-sm-8">
                <input class="form-control" id="productionEnd" name="productionEnd" placeholder="年-月-日" required
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">申请截至时间：</label>
            <div class="col-sm-8">
                <input class="form-control" id="productionOver" name="productionOver" placeholder="年-月-日" required
                       type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">实习单位名称：</label>
            <div class="col-sm-8">
                <input class="form-control" id="productionCompany" name="productionCompany" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">实习单位简介：</label>
            <div class="col-sm-8">
                <textarea class="form-control" id="productionIntro" name="productionIntro" required
                          type="text"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业数量：</label>
            <div class="col-sm-8">
                <input class="form-control" id="productionWeeks" name="productionWeeks" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业要求：</label>
            <div class="col-sm-8">
                <textarea class="form-control" id="productionWeekly" name="productionWeekly" required
                          type="text"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业成绩占比(%)：</label>
            <div class="col-sm-8">
                <input class="form-control" id="pacific" name="pacific" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">总结成绩占比(%)：</label>
            <div class="col-sm-8">
                <input class="form-control" id="exam" name="exam" required type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "sau/production";
    $(function () {
        $("#productionBegin").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $("#productionEnd").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $("#productionOver").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    });

    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        if ($.validate.form()) {
            var productionName = $("input[name='productionName']").val();
            var productionRequire = $("textarea[name='productionRequire']").val();
            var productionBegin = $("input[name='productionBegin']").val();
            var productionEnd = $("input[name='productionEnd']").val();
            var productionOver = $("input[name='productionOver']").val();
            var productionCompany = $("input[name='productionCompany']").val();
            var productionIntro = $("textarea[name='productionIntro']").val();
            var productionWeeks = $("input[name='productionWeeks']").val();
            var productionWeekly = $("textarea[name='productionWeekly']").val();
            var pacific = $("input[name='pacific']").val();
            var exam = $("input[name='exam']").val();
            $.ajax({
                cache: true,
                type: "POST",
                url: ctx + "sau/production/addProduction",
                data: {
                    "productionName": productionName,
                    "productionRequire": productionRequire,
                    "productionBegin": productionBegin,
                    "productionEnd": productionEnd,
                    "productionOver": productionOver,
                    "productionCompany": productionCompany,
                    "productionIntro": productionIntro,
                    "productionWeeks": productionWeeks,
                    "productionWeekly": productionWeekly,
                    "pacific": pacific,
                    "exam": exam
                },
                async: false,
                error: function (request) {
                    $.modal.alertError("系统错误");
                },
                success: function (data) {
                    $.operate.successCallback(data);
                }
            });
        }
    }

</script>
</body>
</html>
